<%@ Page Language="C#" Theme="Defaultsys" AutoEventWireup="true" CodeFile="ContactList.aspx.cs"
    Inherits="ContactList" Title="Rapport Plan System - Contact list" MasterPageFile="~/MasterPage.master" %>

<%@ MasterType VirtualPath="~/MasterPage.master" %>
<asp:Content runat="server" ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1">
    
    <script type="text/javascript" src="jscripts/date/calendar.js"></script>

    <script type="text/javascript" src="jscripts/date/calendar-setup.js"></script>

    <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
            <td class="contTable">
                <asp:Panel ID="pnlContactList" runat="server">
                    <asp:GridView ID="grdContacts" SkinID="gvGrid" runat="server" AutoGenerateColumns="false"
                        AllowPaging="true" OnRowCommand="Command" Width="100%" OnRowDataBound="RowDataBound"
                        OnPageIndexChanging="grdContacts_PageIndexChanging">
                        <Columns>
                            <asp:TemplateField HeaderText="ID" 
                                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="3%">
                                <ItemTemplate>
                                    <%# Container.DataItemIndex + 1 %>
                                </ItemTemplate>
                            </asp:TemplateField>
                            
                            <asp:BoundField HeaderText="Contact" DataField="Name" SortExpression="Name" ItemStyle-Width="50%"
                                HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left"/>
                                
                            <asp:TemplateField HeaderText="View history" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:Button ID="btnViewHistory" runat="server" Text="View history" CommandArgument='<%# Eval("ContactId") %>' />
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="Edit" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:Button ID="btnEdit" runat="server" Text="Edit" CommandArgument='<%# Eval("ContactId") %>' />
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="Remove" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:Button ID="btnRemove" runat="server" Text="Remove" CommandArgument='<%# Eval("ContactId") %>' />
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                        </Columns>
                        <EmptyDataTemplate>
                            There are currently no contacts.</EmptyDataTemplate>
                        <PagerStyle VerticalAlign="Middle" HorizontalAlign="Left" Wrap="False" CssClass="paging"
                            Font-Bold="True"></PagerStyle>
                        <PagerSettings Mode="NumericFirstLast" />
                    </asp:GridView>
                    <asp:Button ID="btnAddNewContact" runat="server" Text="Add new contact" OnClick="AddNewContact" />
                    <asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="OpenSearch" />
                </asp:Panel>
                <asp:Panel ID="pnlSearch" runat="server" Visible="false">
                    <table>
                        <tr>
                            <td>
                                Contact type:</td>
                            <td>
                                <asp:DropDownList ID="ddlContactType" runat="server" Width="231px">
                                </asp:DropDownList></td>
                        </tr>
                        <tr>
                            <td>
                                Name:</td>
                            <td>
                                <asp:TextBox ID="txtName" runat="server" Width="225px" MaxLength="255"></asp:TextBox></td>
                        </tr>
                        <tr>
                            <td>
                                Email address:</td>
                            <td>
                                <asp:TextBox ID="txtEmail" runat="server" Width="225px" MaxLength="255"></asp:TextBox></td>
                        </tr>
                        <tr>
                            <td>
                                Phone no.:</td>
                            <td>
                                <asp:TextBox ID="txtPhone" runat="server" Width="225px" MaxLength="255"></asp:TextBox></td>
                        </tr>
                        <tr>
                            <td>
                                Mobile phone no:</td>
                            <td>
                                <asp:TextBox ID="txtMobilePhoneNo" runat="server" Width="225px" MaxLength="255"></asp:TextBox></td>
                        </tr>
                        <tr>
                            <td>
                                Fax:</td>
                            <td>
                                <asp:TextBox ID="txtFax" runat="server" Width="225px" MaxLength="255"></asp:TextBox></td>
                        </tr>
                        <tr>
                            <td valign="top">
                                Mail address:</td>
                            <td>
                                <asp:TextBox ID="txtMailAddress" runat="server" TextMode="MultiLine" Height="37px"
                                    Width="225px" MaxLength="255"></asp:TextBox></td>
                        </tr>
                        <tr>
                            <td valign="top">
                                Mail city:</td>
                            <td>
                                <asp:TextBox ID="txtCity" runat="server" Width="225px" MaxLength="255"></asp:TextBox></td>
                        </tr>
                        <tr>
                            <td valign="top">
                                Mail state:</td>
                            <td>
                                <asp:DropDownList ID="cmbStates" runat="server" Width="231px">
                                </asp:DropDownList></td>
                        </tr>
                        <tr>
                            <td valign="top">
                                Mail country:</td>
                            <td>
                                <asp:DropDownList ID="cmbCountry" runat="server" Width="231px">
                                </asp:DropDownList></td>
                        </tr>
                        <tr>
                            <td style="height: 26px" valign="top">
                                Mail zip:</td>
                            <td style="height: 26px">
                                <asp:TextBox ID="txtZip" runat="server" Width="225px" MaxLength="255"></asp:TextBox></td>
                        </tr>
                        <tr>
                            <td style="height: 26px" valign="top">
                                Visit date:</td>
                            <td style="height: 26px">
                                <asp:TextBox ID="txtVisitDateFrom" runat="server" MaxLength="255"></asp:TextBox>
                                <img alt="calendar" src="jscripts/date/calendar.gif" id="f_trigger_from" style="cursor: pointer;"
                                    border="0" />
                                &gt;&gt;<asp:TextBox ID="txtVisitDateTo" runat="server" MaxLength="255"></asp:TextBox>
                                <img alt="calendar" src="jscripts/date/calendar.gif" id="f_trigger_to" style="cursor: pointer;"
                                    border="0" /></td>

                            <script type="text/javascript">

    Calendar.setup({
        inputField     :    "ctl00_ContentPlaceHolder1_txtVisitDateFrom",     // id of the input field
        ifFormat       :    "%m/%d/%Y",    // format of the input field
        button         :    "f_trigger_from",  // trigger for the calendar (button ID)
        singleClick    :    true
    });
    
      Calendar.setup({
        inputField     :    "ctl00_ContentPlaceHolder1_txtVisitDateTo",     // id of the input field
        ifFormat       :    "%m/%d/%Y",    // format of the input field
        button         :    "f_trigger_to",  // trigger for the calendar (button ID)
        singleClick    :    true
    });
                            </script>

                        </tr>
                        <tr>
                            <td style="height: 26px" valign="top">
                                Active:</td>
                            <td style="height: 26px">
                                <asp:CheckBox ID="ckActive" runat="server" Text="Active" Checked="true" />
                                <asp:CheckBox ID="ckInactive" runat="server" Text="Inactive" Checked="true" /></td>
                        </tr>
                        <tr>
                            <td colspan="2" style="height: 26px" valign="top">
                                <asp:GridView ID="grdFields"  GridLines="None"  runat="server" AutoGenerateColumns="false" ShowHeader="false"
                                    Width="100%" SkinID="gvGridNone">
                                    <Columns>
                                        <asp:BoundField DataField="Name" HeaderText="Property" ItemStyle-Width="22%" SortExpression="Name" />
                                        <asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type" />
                                        <asp:TemplateField HeaderText="Id" Visible="false">
                                            <ItemTemplate>
                                                <asp:TextBox ID="id" runat="server" Text='<%# Eval("ContactPageFieldId") %>' Visible="false"></asp:TextBox>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>

                                <script type="text/javascript">
        Calendar.setup({
            inputField     :    "ctl00_ContentPlaceHolder1_txtVisitDate",     // id of the input field
            ifFormat       :    "%m/%d/%Y",    // format of the input field
            button         :    "f_trigger_from",  // trigger for the calendar (button ID)
            singleClick    :    true
        });
        
      for (i=0; i<=9; i++){
        if (document.getElementById("ctl00_ContentPlaceHolder1_grdFields_ctl0"+i+"_txtDateTimeId")!= null){
        Calendar.setup({
            inputField     :    "ctl00_ContentPlaceHolder1_grdFields_ctl0"+i+"_txtDateTimeId",     // id of the input field
            ifFormat       :    "%m/%d/%Y",    // format of the input field
            button         :    "ctl00_ContentPlaceHolder1_grdFields_ctl0"+i+"_dateId",  // trigger for the calendar (button ID)
            singleClick    :    true
        });
        }
      }
        
                                </script>

                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" valign="top">
                                <asp:Button ID="btnSearch2" runat="server" Text="Search" OnClick="ShowSearch" />
                                <asp:Button ID="btnCancel" runat="server" Text="Close" OnClick="Cancel" /></td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <asp:Label ID="lblSearchResult" runat="server" ForeColor="Red"></asp:Label>
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
            </td>
        </tr>
    </table>
</asp:Content>
